package cn.shopping.controller.vouchers;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.shopping.pojo.cash_coupon;
import cn.shopping.pojo.coupons;
import cn.shopping.pojo.shopping_voucher;
import cn.shopping.pojo.voucher;
import cn.shopping.service.vouchers.vouchersService;

@Controller
@RequestMapping("/vouchers")
public class vouchersController {

	@Resource
	private vouchersService voucherservices;
	/**
	 * 重消券
	 * @param model
	 * @return
	 */
	
	@RequestMapping("/selallvouvher.html")
	public String selallvouvher(Model model){
		if (voucherservices.selvcount()) {
			if (voucherservices.delvoucher()) {
				List<voucher> list = voucherservices.getvouchers();
				model.addAttribute("voucherList", list);
			}
		}
		List<voucher> list = voucherservices.getvouchers();
		model.addAttribute("voucherList", list);
		return "chongxiaoquan";
	}
	
	/**
	 * 优惠券
	 * @param model
	 * @return
	 */
	@RequestMapping("/selallcoupons.html")
	public String selallcoupons(Model model){
		if (voucherservices.selccount()) {
			if (voucherservices.delcoupons()) {
				List<coupons> list = voucherservices.getcoupons();
				model.addAttribute("couponsList", list);
			}
		}
		List<coupons> list = voucherservices.getcoupons();
		model.addAttribute("couponsList", list);
		return "youhuiquan";
	}
	
	/**
	 * 购物券
	 * @param model
	 * @return
	 */
	@RequestMapping("/selallshopping.html")
	public String selallselallshopping(Model model){
		if (voucherservices.selscount()) {
			if (voucherservices.delshopping_voucher()) {
				List<shopping_voucher> list = voucherservices.getshopping_voucher();
				model.addAttribute("selallshoppingList", list);
			}
		}
		List<shopping_voucher> list = voucherservices.getshopping_voucher();
		model.addAttribute("selallshoppingList", list);
		return "gouwuquan";
	}
	
	
	/**
	 * 代金券
	 * @param model
	 * @return
	 */
	
	@RequestMapping("/selallcash.html")
	public String selallcash(Model model){
		if (voucherservices.selcscount()) {
			if (voucherservices.delcash_coupon()) {
				List<cash_coupon> list = voucherservices.getcash_coupon();
				model.addAttribute("selallcash", list);
			}
		}
		List<cash_coupon> list = voucherservices.getcash_coupon();
		model.addAttribute("selallcash", list);
		return "daijinquan";
	}
	
}
